/**
 * Created with CLion.
 * Description: 
 * User: loong
 * Date: 2025/5/20
 * Time: 23:05
 */

#ifndef ENEMY_H
#define ENEMY_H
#include "core/Actor.h"

class SpriteAnim;
class Player;
class Enemy : public Actor
{
public:
    enum State{
        NORMAL,
        HURT,
        DIE
    };
    static Enemy* AddEnemyChild(Object* _parent, glm::vec2 _pos, Player* _target);

    void Update(float _dt) override;

    void Init() override;

    void     SetTarget(Player * _player) { target_ = _player; };
    Player * GetTarget() const { return target_; };

    ~Enemy() override = default;
private:
    void AimTarget(Player * _target);
    void CheckState();
    void ChangeState(State _state);
    void Remove();
    void Attack();

private:
    Player * target_ {nullptr};
    
    State current_state_  {NORMAL};

    SpriteAnim * anim_normal_  {nullptr};
    SpriteAnim * anim_hurt_  {nullptr};
    SpriteAnim * anim_die_  {nullptr};

    SpriteAnim * current_anim_  {nullptr};

    float timer_  {0.0f};
};

#endif//ENEMY_H
